package com.gk.javaservice.util.base;

import java.io.*;
import java.util.zip.ZipEntry;

//压缩包输出流工具
public class ZipOutputStream {
	public static void main(String[] args) throws Exception {
		File f=new File("E:/icon1.png");
		FileInputStream fis=new FileInputStream(f);
		BufferedInputStream bis=new BufferedInputStream(fis);
		byte [] buf=new byte[1024];
		int len;
		FileOutputStream fos =new FileOutputStream(f.getName()+".zip");
		BufferedOutputStream bos=new BufferedOutputStream(fos);
		//
		java.util.zip.ZipOutputStream zos=new java.util.zip.ZipOutputStream(bos);
		//
		ZipEntry ze=new ZipEntry(f.getName());
		//
		zos.putNextEntry(ze);
		while((len=bis.read(buf))!=-1){
			zos.write(buf, 0, len);
			zos.flush();
		}
		bis.close();
		zos.close();
		
	}
	
}
